* Import data
import delimited "Poland EU referendum results by metro.csv", clear 

* Label raw variables
label var country "Country where polling station is located"
label var metro "Main city of metropolitan area"
label var eligible "Number Polish citizens registered and eligible to vote in metro area, 2003"
label var turnout "Number of ballots cast in metro area in 2003 EU accession referendum"
label var yes "Number of votes favoring EU accession in 2003 referendum in metro area"
label var no "Number of votes opposing EU accession in 2003 referendum in metro area"
label var age "Age in years of oldest continuously operating Polish organization in metro"
label var unpop2003 "Metropolitan area population, 2003"
label var unpop1993 "Metropolitan area population, 1993"
label var distance "Kilometers from polling station to nearest point in Poland"
label var eu "Metropolitan area is in pre-2003 European Union member"
label var neu "Metropolitan area is in country prospectively joining EU alongside Poland"
label var gawccat "Taylor et al. (2003) classification of metropolitan cosmopolitanism"
label var capital "Metropolitan area contains capital city"

* Process variables
gen pctno = 100*no/valid
gen lnpctno = ln(1 + pctno)
gen lnage = ln(1 + age)
gen lndist = ln(distance)
gen lnpop = ln(unpop2003)
gen lnturnout = ln(turnout)
gen ihspopch = asinh(unpop2003/unpop1993 - 1)

* Label transformed variables
label var pctno "Percentage of valid votes opposing EU accession"
label var lnpctno "Quasi-logarithmic transformation of vote share opposing EU accession"
label var lnage "Quasi-logarithmic transformation of age of oldest Polish organization"
label var lndist "Logarithmic transformation of distance to Poland"
label var lnpop "Logarithmic tranformation of metropolitan population size"
label var lnturnout "Logarithmic transformation of number of ballots cast"
label var ihspopch "Inverse hyperbolic sine of ten-year population-growth rate"

* Table 1 models
reg pctno age lnturnout lnpop ihspopch gawccat lndist eu neu capital [aweight = turnout], cl(country)
reg pctno lnage lnturnout lnpop ihspopch gawccat lndist eu neu capital [aweight = turnout], cl(country)
reg lnpctno age lnturnout lnpop ihspopch gawccat lndist eu neu capital [aweight = turnout], cl(country)
reg lnpctno lnage lnturnout lnpop ihspopch gawccat lndist eu neu capital [aweight = turnout], cl(country)
